Given /^navigate to the page "([^\"]*)"$/ do |testURL|
  @browser.goto testURL
  #  @browser.close
end

When /^wait text_field component with id="([^\"]*)" to load$/ do |componentID|
  Watir::Waiter::wait_until { @browser.text_field(:id, componentID).exists? }
end

When /^page loaded after timeout in ([^\"]*) seconds$/ do |timeout|
  @browser.wait()
  sleep(timeout.to_i)
end

And /^text "([^\"]*)" present on the page/ do |reqText|
  assert_match(reqText, @browser.text)
end

And /^check if text component with id="([^\"]*)" contain text "([^\"]*)"$/ do |componentID, reqText|
  assert_equal(reqText, @browser.text_field(:id,componentID).text)
end

And /^press button with id="([^\"]*)"$/ do |componentID|
  @browser.button(:id,componentID).click
end

Then /^serch in text component with id="([^\"]*)" text "([^\"]*)"$/ do |componentID, searchText|
  @browser.text_field(:id,componentID).set(searchText)
end

Then /^check checkbox componen with id="([^\"]*)"$/ do |componentID|
  @browser.checkbox(:id,componentID).set
end

Then /^uncheck checkbox componen with id="([^\"]*)"$/ do |componentID|
  @browser.checkbox(:id,componentID).clear
end

Then /^select radiobutton componen with id="([^\"]*)"$/ do |componentID|
  @browser.radio(:id,componentID).set
end

Then /^select each value in checkList with id="([^\"]*)"$/ do |componentID|
  i=0;
  a = Array.new(@browser.select_list(:id, componentID).getAllContents)
  size = a.size
  while i<size do
    @browser.select_list(:id,componentID).set(a[i])
    assert_equal(a[i], @browser.select_list(:id,componentID).value)
    i=i+1
  end
end